/* model */
import Field from "@model/entity/Field";
/* util */
import { randomString } from 'pub-bbx-utils';
import { getRootWindow } from '@src/util/dom';

const RootWindow = getRootWindow(window);
const serviceHotLine = RootWindow?.grayAuth?.SERVICE_HOT_LINE ?? false;

interface expandField extends Field {
  disabled?: number
}

const formCompanyInfoSettingAvatarField = (isValidate: boolean): Field => {
  return {
    defaultValue: null,
    displayName: "公司logo",
    fieldName: "avatar",
    formType: "text",
    guideProfessions: [],
    id: randomString(),
    isDelete: 0,
    isGuideData: false,
    isNull: isValidate ? 0 : 1,
    isSearch: 0,
    isSystem: 0,
    orderId: 0,
    maxlength: 50,
    placeHolder: '前往公司信息设置修改',
    setting: {},
  }
}

const formCompanyInfoSettingNameField = (isValidate: boolean): expandField => {
  return {
    defaultValue: null,
    displayName: "公司名称",
    fieldName: "name",
    formType: "text",
    guideProfessions: [],
    id: randomString(),
    isDelete: 0,
    isGuideData: false,
    isNull: isValidate ? 0 : 1,
    isSearch: 0,
    isSystem: 0,
    orderId: 0,
    maxlength: 50,
    placeHolder: '前往公司信息设置修改',
    disabled: 1,
    setting: {},
  }
}

const formCompanyInfoSettingPhoneField = (isValidate: boolean): expandField => {
  return {
    defaultValue: null,
    displayName: serviceHotLine ? '服务热线' : "公司电话",
    fieldName: "phone",
    formType: "text",
    guideProfessions: [],
    id: randomString(),
    isDelete: 0,
    isGuideData: false,
    isNull: isValidate ? 0 : 1,
    isSearch: 0,
    isSystem: 0,
    orderId: 0,
    maxlength: 50,
    placeHolder: '前往公司信息设置修改',
    disabled: 1,
    setting: {},
  }
}

const formCompanyInfoSettingEmailField = (isValidate: boolean): expandField => {
  return {
    defaultValue: null,
    displayName: "公司邮箱",
    fieldName: "email",
    formType: "text",
    guideProfessions: [],
    id: randomString(),
    isDelete: 0,
    isGuideData: false,
    isNull: isValidate ? 0 : 1,
    isSearch: 0,
    isSystem: 0,
    orderId: 0,
    maxlength: 50,
    placeHolder: '前往公司信息设置修改',
    disabled: 1,
    setting: {},
  }
}

const formCompanyInfoSettingAddressField = (isValidate: boolean): expandField => {
  return {
    defaultValue: null,
    displayName: "公司地址",
    fieldName: "address",
    formType: "text",
    guideProfessions: [],
    id: randomString(),
    isDelete: 0,
    isGuideData: false,
    isNull: isValidate ? 0 : 1,
    isSearch: 0,
    isSystem: 0,
    orderId: 0,
    maxlength: 50,
    placeHolder: '前往公司信息设置修改',
    disabled: 1,
    setting: {},
  }
}

export {
  formCompanyInfoSettingAvatarField,
  formCompanyInfoSettingNameField,
  formCompanyInfoSettingPhoneField,
  formCompanyInfoSettingEmailField,
  formCompanyInfoSettingAddressField,
}

export default {
  formCompanyInfoSettingAvatarField,
  formCompanyInfoSettingNameField,
  formCompanyInfoSettingPhoneField,
  formCompanyInfoSettingEmailField,
  formCompanyInfoSettingAddressField
}
